<template>
  <div>
    <el-row :gutter="24">
      <el-col :span="8" :offset="8">
        <div class="grid-content"></div>
      </el-col>
    </el-row>
    <el-row :gutter="24">
      <el-col :span="8" :offset="8">
        <el-input v-model="adminusername" placeholder="请输入内容"></el-input>
        <el-input
          v-model="adminuserpassword"
          placeholder="请输入密码"
          show-password
        ></el-input>
        <el-button type="primary" @click="login()">登录</el-button>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: "AdminLogin",
  data() {
    return {
      adminusername: "",
      adminuserpassword: "",
    };
  },
  methods: {
    login() {
      let that = this;
      this.axios({
        method: "post",
        url: this.$constant.url + "/adminuser/login",
        data: {
          adminusername: that.adminusername,
          adminuserpassword: that.adminuserpassword,
        },
      }).then(({ data }) => {
        if (data.code == 100) {
          window.sessionStorage.setItem("token", data.data);
          that.$router.push({ path: "/admin/index" });
        } else {
          alert("重新的登录");
        }
      });
    },
  },
};
</script>

<style>
</style>
